package hms.inventory;

/**
 * CatalogItem is a catalog item.
 * 
 * @author Akilah McIntyre
 */
public class CatalogItem {
	/**
	 * unique identifier of a catalog item
	 */
	public int catlg_item_id = -1;
	/**
	 * name of a catalog item
	 */
	public String catlg_item_name = "";

	/**
	 * Constructs a catalog item from an unique identifier and a name.
	 * 
	 * @param catlg_item_nameID
	 *            unique identifier of a catalog item
	 * @param catlg_item_name
	 *            name of of a catalog item
	 * 
	 **/
	public CatalogItem(int catlg_item_nameID, String catlg_item_name) {
		this.catlg_item_id = catlg_item_nameID;
		this.catlg_item_name = catlg_item_name;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + catlg_item_id;
		result = prime * result
				+ ((catlg_item_name == null) ? 0 : catlg_item_name.hashCode());
		return result;
	}

	/**
	 * Compares two catalog items for equality. The result is true if and only
	 * if the argument is not null and is a CatalogItem object has the same
	 * unique identifier and name as this object.
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (!(obj instanceof CatalogItem)) {
			return false;
		}
		CatalogItem other = (CatalogItem) obj;
		if (catlg_item_id != other.catlg_item_id) {
			return false;
		}
		if (catlg_item_name == null) {
			if (other.catlg_item_name != null) {
				return false;
			}
		} else if (!catlg_item_name.equals(other.catlg_item_name)) {
			return false;
		}
		return true;
	}

	/**
	 * Returns a string representation of this CatalogItem, which is
	 * catlg_item_name
	 **/
	public String toString() {
		return catlg_item_name;
	}
}
